import Rx = require('rxjs')

export = function(io: any) {
    io.on('connection', (socket: any) => {
        console.log('socket connection')
        // Rx.Observable.interval(1000).subscribe({
        //     next: (x) => socket.emit('news', { hello: 'world ' + x })
        // })

        socket.on('disconnect', () => {
            console.log('socket disconnect')
        })
    })

    // Registering Socket.io middleware
    io.use((socket: any, next: Function) => {
        // Exposing a request property to services and hooks
        socket.feathers.referrer = socket.request.referrer;
        next()
    })

    // io.use((socket, next) => {
    //   // Authorize using the /users service
    //   app.service('users').find({
    //     username: socket.request.username,
    //     password: socket.request.password
    //   }, next)
    // })

}